package com.biqee.model.page;

import java.math.BigDecimal;

import com.biqee.model.db.BqTuan;
import com.biqee.util.BigDecimalUtil;

public class ItemTuanVO {

	private BqTuan bqTuan;

	public BqTuan getBqTuan() {
		return bqTuan;
	}

	public void setBqTuan(BqTuan bqTuan) {
		this.bqTuan = bqTuan;
	}

	public BigDecimal getDiscount() {
		if (this.bqTuan.getOldPrice() != null
				&& this.bqTuan.getTuanPrice() != null) {
			BigDecimal oldPrice = new BigDecimal(this.bqTuan.getOldPrice());
			BigDecimal tuanPrice = new BigDecimal(this.bqTuan.getTuanPrice());
			BigDecimal discount = BigDecimalUtil.defaultDivide(tuanPrice, oldPrice);
			return BigDecimalUtil.multiply(discount, new BigDecimal(10));
		} else {
			return null;
		}
	}
	
	public BigDecimal getSave(){
		if (this.bqTuan.getOldPrice() != null
				&& this.bqTuan.getTuanPrice() != null) {
			BigDecimal oldPrice = new BigDecimal(this.bqTuan.getOldPrice());
			BigDecimal tuanPrice = new BigDecimal(this.bqTuan.getTuanPrice());
			return BigDecimalUtil.subtract(oldPrice, tuanPrice);
		} else {
			return null;
		}
	}

	
}
